#include <iostream>
using namespace std;


int main()
{
	int n, len, time = 0, tmp = 0;
	cin >> n >> len;
	
	int* L = new int[n];
	int* S = new int[n];
	int* arr = new int[len];
	for (int i = 0; i < len; ++i)
		arr[i] = 0;


	for (int i = 0; i < n; ++i)
		cin >> L[i] >> S[i];

	while (tmp < len)
	{
		++time;
		for (int i = 0; i < n; ++i)
		{
			if ((time - S[i]) >= 0)
			{
				int start = L[i] - (time - S[i]) - 1;
				int end = L[i] + (time - S[i]) - 1;
				if (start >= 0 && arr[start] == 0)
				{
					arr[start] = 1;
					++tmp;
				}
				if (end < len && arr[end] == 0)
				{
					arr[end] = 1;
					++tmp;
				}
			}
		}
	}
	cout << time << endl;

	delete[] L;
	delete[] S;
	delete[] arr;

	return 0;
}
